home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- | Description:
- | This file defines the Interface class. It creates and manages
- | the pulldown menus for noodle.
- |
- | Author(s): Paul Isaacs
- |
- */
-
- #ifndef _INTERFACE_
- #define _INTERFACE_
-
- #include <Xm/Xm.h>
-
- #include <Inventor/SbLinear.h>
- #include <Inventor/SoLists.h>
- #include <Inventor/nodes/SoSelection.h>
-
- extern class GeneralizedCylinder;
- extern class WorldInfo;
- extern class SoXtViewer;
- extern class NoodleTextureGizmo;
- extern class NoodleSurfaceGizmo;
-
- class Interface;
-
- struct NoodleButtonInfo {
- char *name;
- int id;
- int buttonType; // PUSH, TOGGLE, RADIO
- SbBool isOn; // relevant for toggles.
- char *accelerator; // e.g. "Alt <Key> p"
- char *accelText; // text that appears in the menu item
- };
-
- struct NoodleMenuItem {
- int id;
- Widget widget;
- Interface *ownerInterface;
- };
-
- struct NoodleMenu {
- char *name;
- int id;
- struct NoodleButtonInfo *subMenu;
- int subItemCount;
- };
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // Class: Interface
- //
- //////////////////////////////////////////////////////////////////////////////
-
- class Interface {
-
- public:
-
- Interface();
- ~Interface();
-
- // Builds widgets for the top bar menus
- Widget build( Widget parentWidget );
-
- void setWorldInfo( WorldInfo *newWorldInfo );
- WorldInfo *getWorldInfo() { return worldInfo; }
-
- void setMainViewer( SoXtViewer *newMainViewer )
- { mainViewer = newMainViewer; }
- SoXtViewer *getMainViewer() { return mainViewer; }
-
- void setProfileViewer( SoXtViewer *newV ) { profileViewer = newV; }
- void setSectionViewer( SoXtViewer *newV ) { sectionViewer = newV; }
- void setSpineViewer( SoXtViewer *newV ) { spineViewer = newV; }
- void setTwistViewer( SoXtViewer *newV ) { twistViewer = newV; }
-
- void setProfileCloseButton( Widget newW ) { closeProfileButton = newW; }
- void setSectionCloseButton( Widget newW ) { closeSectionButton = newW; }
- void setSpineCloseButton( Widget newW ) { closeSpineButton = newW; }
- void setTwistCloseButton( Widget newW ) { closeTwistButton = newW; }
-
- SbColor getBackgroundColor() { return bgColor; }
- void setBackgroundColor( SbColor newColor ) { bgColor = newColor; }
-
- // Reads the scene given by filename and puts the results into worldInfo.
- // Returns pointer to top of scene graph.
- // If filename is NULL, uses name already found in worldInfo.
- // If filename and worldInfo are both NULL, it is an error.
- SoSeparator *readScene( char *newFileName = NULL, SbBool okIfNoName =FALSE);
-
- // Writes the scene contained in worldInfo.
- // If asVanilla==FALSE, uses special GeneralizedCylinder class in the file.
- // If asVanilla==TRUE, uses only standard Inventor nodes.
- // If filename is NULL, uses name already found in worldInfo.
- // If filename and worldInfo are both NULL, it is an error.
- void writeToFile( SbBool asVanilla, char *newFileName = NULL );
-
- // Sets info in the interface to reflect contents.
- void setPrimarySelection( GeneralizedCylinder *g );
-
- protected:
-
- // Callback added to WorldInfo's selection node to invoke
- // setPrimarySelection() on the new selection.
- static void selectionCB( void *, SoPath *);
-
- WorldInfo *worldInfo;
-
- // Processes events for the top bar menus
- static void processTopbarEvent(Widget, NoodleMenuItem *,
- XmAnyCallbackStruct *);
-
- // These get done in response to events in the pull down menu.
- void fileNewEvent();
- void fileOpenEvent();
- void fileSaveEvent();
- void fileSaveAsEvent();
- void fileSaveVanillaEvent();
- void fileQuitEvent();
-
- // These build dialogs and/or call up showcase to give info.
- void createOkayCancelDialog(Widget, XtCallbackProc,char *,char *,char *);
- void showAboutDialog();
- void showFileSelectionDialog( XtCallbackProc okCB );
-
- // These callbacks from the dialog boxes cause other actions to be taken.
- static void destroyDialogCB(Widget dialog, void *, void *);
-
- // Callback functions relating to the FILE menu.
- static void newSceneCB(Widget, void *, void *);
- static void openSceneCB(Widget, void *, void *);
- static void readFromFileCB(Widget, void *,
- XmFileSelectionBoxCallbackStruct *);
- static void writeToFileCB(Widget, void *,
- XmFileSelectionBoxCallbackStruct *);
- static void writeToVanillaFileCB(Widget, void *,
- XmFileSelectionBoxCallbackStruct *);
- static void quitProgramCB(Widget, void *, void *);
-
- private:
-
- void setRenderStyleRadioButtons(
- GeneralizedCylinder::RenderShapeType shapeType );
- void setManipTypeRadioButtons( const SoType &manipType );
-
- SbColor bgColor;
- SoXtViewer *mainViewer; // The viewer used to display the scene.
-
- Widget mgrWidget;
- NoodleMenuItem *menuItems;
-
- NoodleTextureGizmo *myTextureGizmo;
- NoodleSurfaceGizmo *mySurfaceGizmo;
-
- SoXtViewer *profileViewer;
- SoXtViewer *sectionViewer;
- SoXtViewer *spineViewer;
- SoXtViewer *twistViewer;
-
- Widget closeProfileButton;
- Widget closeSectionButton;
- Widget closeSpineButton;
- Widget closeTwistButton;
- };
-
- #endif /* _INTERFACE_ */
-